#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <fstream>
#include <limits.h>
#include <queue>
#include <pthread.h>
#include <semaphore.h>

typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef struct str_threaddata{
	int threadID;
} threadData;

//Prototypes
void init();
void* receive(void* ptr);
int processPacket(uchar* data, int numbytes);
ushort cksum(uchar* addr, int count);
bool isBOF(uchar* data);
bool isEOF(uchar* data);
bool isPING(uchar* data);
void sendPING(uchar* data);
void printdata(uchar* data, int count);
ushort getChecksum(uchar* data);
void clearChecksum(uchar* addr);
void sendAck(uchar* ack, uint sequenceNumber);
uint getSeqNum(uchar* data);
void setSeqNum(uchar* packet, uint sequenceNumber);
void *get_in_addr(struct sockaddr *sa);
int bindSocket();
void cleanup();
